function check(){
	var inputObjects = document.getElementsByTagName("input");
	var bool = false;
	for ( var i = 0; i < inputObjects.length; i++) {
		if(inputObjects[i].id.indexOf("_")!=-1){
			if(document.getElementById(inputObjects[i].id).checked){
				bool=true;
			}
		}
	}
	if(bool==false){
		alert('请至少选择一项');
		return false;
	}
	document.form1.submit();
	return true;
}

function choose(str){
	var check;
	if(document.getElementById(str).checked){
		//选中
		check = true;
	}else{
		//未选
		check=false;
	}
	var cd = str.substring(str.length-1,str.length);
	var inputObjects = document.getElementsByTagName("input");
	//一级菜单
	if(cd==1){
		chooseSel(inputObjects,str,1,check);
	}
	//二级菜单
	
	if (cd == 2) {
		if (check) {
			//选中一级菜单
			document.getElementById(str.split("_")[0]).checked = check;
		} else {
			calOne(inputObjects, str);
		}
		chooseSel(inputObjects, str, 2, check);
	}
		//三级菜单
	if (cd == 3) {
		if (check) {
			//选中一级菜单
			document.getElementById(str.split("_")[0]).checked = check;
			document.getElementById(str.split("_")[0]+"_"+str.split("_")[1]).checked = check;
		} else {
			calTwo(inputObjects, str);
		}
		chooseSel(inputObjects, str, 3, check);
	}
		//四级菜单
    if (cd == 4) {
    	if (check) {
			//选中一级菜单
			document.getElementById(str.split("_")[0]).checked = check;
			document.getElementById(str.split("_")[0]+"_"+str.split("_")[1]).checked = check;
			document.getElementById(str.split("_")[0]+"_"+str.split("_")[1]+"_"+str.split("_")[2]).checked = check;
		} else {
			calThree(inputObjects, str);
		}
		chooseSel(inputObjects, str, 4, check);
	}
}

	function chooseSel(inputObjects, str, j, check) {
		for ( var i = 0; i < inputObjects.length; i++) {
			var dd = inputObjects[i].id.split("_");
			if (dd.length = j) {
				if (str.split("_")[j - 1] == dd[j - 1]) {
					document.getElementById(inputObjects[i].id).checked = check;
				}
			}
		}
	}
	//判断一级菜单是否应该取消
	function calOne(inputObjects, str) {
		var bool=false;
		for ( var i = 0; i < inputObjects.length; i++) {
			var dd = inputObjects[i].id.split("_");
			if (dd.length == 2) {
				if (dd[1].indexOf('2')!= -1) {
					if (document.getElementById(dd[0]+"_"+dd[1]).checked) {
						bool = true;
					}
				}

			}
		}
		document.getElementById(str.split("_")[0]).checked = bool;
	}
	
	//判断二级菜单是否应该取消
	function calTwo(inputObjects, str) {
		var str1 = str.split("_");
		var bool=false;
		for ( var i = 0; i < inputObjects.length; i++) {
			var dd = inputObjects[i].id.split("_");
			if (dd.length == 3) {
				if (dd[2].indexOf('3')!= -1&&dd[1]==str1[1]) {
					if (document.getElementById(dd[0]+"_"+dd[1]+"_"+dd[2]).checked) {
						
						bool = true;
					}
				}

			}
		}
		document.getElementById(str1[0]+"_"+str1[1]).checked = bool;
		calOne(inputObjects, str);
	}
	
	//判断三级菜单是否应该取消
	function calThree(inputObjects, str) {
		var str1 = str.split("_");
		var bool=false;
		for ( var i = 0; i < inputObjects.length; i++) {
			var dd = inputObjects[i].id.split("_");
			if (dd.length == 4) {
				if (dd[3].indexOf('4')!= -1&&dd[2]==str1[2]) {
					if (document.getElementById(dd[0]+"_"+dd[1]+"_"+dd[2]+"_"+dd[3]).checked) {
						
						bool = true;
					}
				}

			}
		}
		document.getElementById(str1[0]+"_"+str1[1]+"_"+str1[2]).checked = bool;
		calTwo(inputObjects, str);
	}